home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / elispman.lha / elispman / elisp-2 (.txt) < prev    next >
GNU Info File  |  1993-06-01  |  46KB  |  773 lines

  1. This is Info file elisp, produced by Makeinfo-1.55 from the input file
  2. elisp.texi.
  3.    This is edition 2.0 of the GNU Emacs Lisp Reference Manual, for
  4. Emacs Version 19.
  5.    Published by the Free Software Foundation, 675 Massachusetts Avenue,
  6. Cambridge, MA 02139 USA
  7.    Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
  8.    Permission is granted to make and distribute verbatim copies of this
  9. manual provided the copyright notice and this permission notice are
  10. preserved on all copies.
  11.    Permission is granted to copy and distribute modified versions of
  12. this manual under the conditions for verbatim copying, provided that
  13. the entire resulting derived work is distributed under the terms of a
  14. permission notice identical to this one.
  15.    Permission is granted to copy and distribute translations of this
  16. manual into another language, under the above conditions for modified
  17. versions, except that this permission notice may be stated in a
  18. translation approved by the Foundation.
  19. File: elisp,  Node: Copying,  Next: Introduction,  Prev: Top,  Up: Top
  20. GNU GENERAL PUBLIC LICENSE
  21. **************************
  22.                          Version 2, June 1991
  23.      Copyright (C) 1989, 1991 Free Software Foundation, Inc.
  24.      675 Mass Ave, Cambridge, MA 02139, USA
  25.      
  26.      Everyone is permitted to copy and distribute verbatim copies
  27.      of this license document, but changing it is not allowed.
  28. Preamble
  29. ========
  30.    The licenses for most software are designed to take away your
  31. freedom to share and change it.  By contrast, the GNU General Public
  32. License is intended to guarantee your freedom to share and change free
  33. software--to make sure the software is free for all its users.  This
  34. General Public License applies to most of the Free Software
  35. Foundation's software and to any other program whose authors commit to
  36. using it.  (Some other Free Software Foundation software is covered by
  37. the GNU Library General Public License instead.)  You can apply it to
  38. your programs, too.
  39.    When we speak of free software, we are referring to freedom, not
  40. price.  Our General Public Licenses are designed to make sure that you
  41. have the freedom to distribute copies of free software (and charge for
  42. this service if you wish), that you receive source code or can get it
  43. if you want it, that you can change the software or use pieces of it in
  44. new free programs; and that you know you can do these things.
  45.    To protect your rights, we need to make restrictions that forbid
  46. anyone to deny you these rights or to ask you to surrender the rights.
  47. These restrictions translate to certain responsibilities for you if you
  48. distribute copies of the software, or if you modify it.
  49.    For example, if you distribute copies of such a program, whether
  50. gratis or for a fee, you must give the recipients all the rights that
  51. you have.  You must make sure that they, too, receive or can get the
  52. source code.  And you must show them these terms so they know their
  53. rights.
  54.    We protect your rights with two steps: (1) copyright the software,
  55. and (2) offer you this license which gives you legal permission to copy,
  56. distribute and/or modify the software.
  57.    Also, for each author's protection and ours, we want to make certain
  58. that everyone understands that there is no warranty for this free
  59. software.  If the software is modified by someone else and passed on, we
  60. want its recipients to know that what they have is not the original, so
  61. that any problems introduced by others will not reflect on the original
  62. authors' reputations.
  63.    Finally, any free program is threatened constantly by software
  64. patents.  We wish to avoid the danger that redistributors of a free
  65. program will individually obtain patent licenses, in effect making the
  66. program proprietary.  To prevent this, we have made it clear that any
  67. patent must be licensed for everyone's free use or not licensed at all.
  68.    The precise terms and conditions for copying, distribution and
  69. modification follow.
  70.     TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
  71.   1. This License applies to any program or other work which contains a
  72.      notice placed by the copyright holder saying it may be distributed
  73.      under the terms of this General Public License.  The "Program",
  74.      below, refers to any such program or work, and a "work based on
  75.      the Program" means either the Program or any derivative work under
  76.      copyright law: that is to say, a work containing the Program or a
  77.      portion of it, either verbatim or with modifications and/or
  78.      translated into another language.  (Hereinafter, translation is
  79.      included without limitation in the term "modification".)  Each
  80.      licensee is addressed as "you".
  81.      Activities other than copying, distribution and modification are
  82.      not covered by this License; they are outside its scope.  The act
  83.      of running the Program is not restricted, and the output from the
  84.      Program is covered only if its contents constitute a work based on
  85.      the Program (independent of having been made by running the
  86.      Program).  Whether that is true depends on what the Program does.
  87.   2. You may copy and distribute verbatim copies of the Program's
  88.      source code as you receive it, in any medium, provided that you
  89.      conspicuously and appropriately publish on each copy an appropriate
  90.      copyright notice and disclaimer of warranty; keep intact all the
  91.      notices that refer to this License and to the absence of any
  92.      warranty; and give any other recipients of the Program a copy of
  93.      this License along with the Program.
  94.      You may charge a fee for the physical act of transferring a copy,
  95.      and you may at your option offer warranty protection in exchange
  96.      for a fee.
  97.   3. You may modify your copy or copies of the Program or any portion
  98.      of it, thus forming a work based on the Program, and copy and
  99.      distribute such modifications or work under the terms of Section 1
  100.      above, provided that you also meet all of these conditions:
  101.        a. You must cause the modified files to carry prominent notices
  102.           stating that you changed the files and the date of any change.
  103.        b. You must cause any work that you distribute or publish, that
  104.           in whole or in part contains or is derived from the Program
  105.           or any part thereof, to be licensed as a whole at no charge
  106.           to all third parties under the terms of this License.
  107.        c. If the modified program normally reads commands interactively
  108.           when run, you must cause it, when started running for such
  109.           interactive use in the most ordinary way, to print or display
  110.           an announcement including an appropriate copyright notice and
  111.           a notice that there is no warranty (or else, saying that you
  112.           provide a warranty) and that users may redistribute the
  113.           program under these conditions, and telling the user how to
  114.           view a copy of this License.  (Exception: if the Program
  115.           itself is interactive but does not normally print such an
  116.           announcement, your work based on the Program is not required
  117.           to print an announcement.)
  118.      These requirements apply to the modified work as a whole.  If
  119.      identifiable sections of that work are not derived from the
  120.      Program, and can be reasonably considered independent and separate
  121.      works in themselves, then this License, and its terms, do not
  122.      apply to those sections when you distribute them as separate
  123.      works.  But when you distribute the same sections as part of a
  124.      whole which is a work based on the Program, the distribution of
  125.      the whole must be on the terms of this License, whose permissions
  126.      for other licensees extend to the entire whole, and thus to each
  127.      and every part regardless of who wrote it.
  128.      Thus, it is not the intent of this section to claim rights or
  129.      contest your rights to work written entirely by you; rather, the
  130.      intent is to exercise the right to control the distribution of
  131.      derivative or collective works based on the Program.
  132.      In addition, mere aggregation of another work not based on the
  133.      Program with the Program (or with a work based on the Program) on
  134.      a volume of a storage or distribution medium does not bring the
  135.      other work under the scope of this License.
  136.   4. You may copy and distribute the Program (or a work based on it,
  137.      under Section 2) in object code or executable form under the terms
  138.      of Sections 1 and 2 above provided that you also do one of the
  139.      following:
  140.        a. Accompany it with the complete corresponding machine-readable
  141.           source code, which must be distributed under the terms of
  142.           Sections 1 and 2 above on a medium customarily used for
  143.           software interchange; or,
  144.        b. Accompany it with a written offer, valid for at least three
  145.           years, to give any third party, for a charge no more than your
  146.           cost of physically performing source distribution, a complete
  147.           machine-readable copy of the corresponding source code, to be
  148.           distributed under the terms of Sections 1 and 2 above on a
  149.           medium customarily used for software interchange; or,
  150.        c. Accompany it with the information you received as to the offer
  151.           to distribute corresponding source code.  (This alternative is
  152.           allowed only for noncommercial distribution and only if you
  153.           received the program in object code or executable form with
  154.           such an offer, in accord with Subsection b above.)
  155.      The source code for a work means the preferred form of the work for
  156.      making modifications to it.  For an executable work, complete
  157.      source code means all the source code for all modules it contains,
  158.      plus any associated interface definition files, plus the scripts
  159.      used to control compilation and installation of the executable.
  160.      However, as a special exception, the source code distributed need
  161.      not include anything that is normally distributed (in either
  162.      source or binary form) with the major components (compiler,
  163.      kernel, and so on) of the operating system on which the executable
  164.      runs, unless that component itself accompanies the executable.
  165.      If distribution of executable or object code is made by offering
  166.      access to copy from a designated place, then offering equivalent
  167.      access to copy the source code from the same place counts as
  168.      distribution of the source code, even though third parties are not
  169.      compelled to copy the source along with the object code.
  170.   5. You may not copy, modify, sublicense, or distribute the Program
  171.      except as expressly provided under this License.  Any attempt
  172.      otherwise to copy, modify, sublicense or distribute the Program is
  173.      void, and will automatically terminate your rights under this
  174.      License.  However, parties who have received copies, or rights,
  175.      from you under this License will not have their licenses
  176.      terminated so long as such parties remain in full compliance.
  177.   6. You are not required to accept this License, since you have not
  178.      signed it.  However, nothing else grants you permission to modify
  179.      or distribute the Program or its derivative works.  These actions
  180.      are prohibited by law if you do not accept this License.
  181.      Therefore, by modifying or distributing the Program (or any work
  182.      based on the Program), you indicate your acceptance of this
  183.      License to do so, and all its terms and conditions for copying,
  184.      distributing or modifying the Program or works based on it.
  185.   7. Each time you redistribute the Program (or any work based on the
  186.      Program), the recipient automatically receives a license from the
  187.      original licensor to copy, distribute or modify the Program
  188.      subject to these terms and conditions.  You may not impose any
  189.      further restrictions on the recipients' exercise of the rights
  190.      granted herein.  You are not responsible for enforcing compliance
  191.      by third parties to this License.
  192.   8. If, as a consequence of a court judgment or allegation of patent
  193.      infringement or for any other reason (not limited to patent
  194.      issues), conditions are imposed on you (whether by court order,
  195.      agreement or otherwise) that contradict the conditions of this
  196.      License, they do not excuse you from the conditions of this
  197.      License.  If you cannot distribute so as to satisfy simultaneously
  198.      your obligations under this License and any other pertinent
  199.      obligations, then as a consequence you may not distribute the
  200.      Program at all.  For example, if a patent license would not permit
  201.      royalty-free redistribution of the Program by all those who
  202.      receive copies directly or indirectly through you, then the only
  203.      way you could satisfy both it and this License would be to refrain
  204.      entirely from distribution of the Program.
  205.      If any portion of this section is held invalid or unenforceable
  206.      under any particular circumstance, the balance of the section is
  207.      intended to apply and the section as a whole is intended to apply
  208.      in other circumstances.
  209.      It is not the purpose of this section to induce you to infringe any
  210.      patents or other property right claims or to contest validity of
  211.      any such claims; this section has the sole purpose of protecting
  212.      the integrity of the free software distribution system, which is
  213.      implemented by public license practices.  Many people have made
  214.      generous contributions to the wide range of software distributed
  215.      through that system in reliance on consistent application of that
  216.      system; it is up to the author/donor to decide if he or she is
  217.      willing to distribute software through any other system and a
  218.      licensee cannot impose that choice.
  219.      This section is intended to make thoroughly clear what is believed
  220.      to be a consequence of the rest of this License.
  221.   9. If the distribution and/or use of the Program is restricted in
  222.      certain countries either by patents or by copyrighted interfaces,
  223.      the original copyright holder who places the Program under this
  224.      License may add an explicit geographical distribution limitation
  225.      excluding those countries, so that distribution is permitted only
  226.      in or among countries not thus excluded.  In such case, this
  227.      License incorporates the limitation as if written in the body of
  228.      this License.
  229.  10. The Free Software Foundation may publish revised and/or new
  230.      versions of the General Public License from time to time.  Such
  231.      new versions will be similar in spirit to the present version, but
  232.      may differ in detail to address new problems or concerns.
  233.      Each version is given a distinguishing version number.  If the
  234.      Program specifies a version number of this License which applies
  235.      to it and "any later version", you have the option of following
  236.      the terms and conditions either of that version or of any later
  237.      version published by the Free Software Foundation.  If the Program
  238.      does not specify a version number of this License, you may choose
  239.      any version ever published by the Free Software Foundation.
  240.  11. If you wish to incorporate parts of the Program into other free
  241.      programs whose distribution conditions are different, write to the
  242.      author to ask for permission.  For software which is copyrighted
  243.      by the Free Software Foundation, write to the Free Software
  244.      Foundation; we sometimes make exceptions for this.  Our decision
  245.      will be guided by the two goals of preserving the free status of
  246.      all derivatives of our free software and of promoting the sharing
  247.      and reuse of software generally.
  248.                                 NO WARRANTY
  249.  12. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO
  250.      WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE
  251.      LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
  252.      HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
  253.      WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT
  254.      NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  255.      FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE
  256.      QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
  257.      PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY
  258.      SERVICING, REPAIR OR CORRECTION.
  259.  13. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
  260.      WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY
  261.      MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE
  262.      LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL,
  263.      INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR
  264.      INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
  265.      DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU
  266.      OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY
  267.      OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN
  268.      ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
  269.                       END OF TERMS AND CONDITIONS
  270. How to Apply These Terms to Your New Programs
  271. =============================================
  272.    If you develop a new program, and you want it to be of the greatest
  273. possible use to the public, the best way to achieve this is to make it
  274. free software which everyone can redistribute and change under these
  275. terms.
  276.    To do so, attach the following notices to the program.  It is safest
  277. to attach them to the start of each source file to most effectively
  278. convey the exclusion of warranty; and each file should have at least
  279. the "copyright" line and a pointer to where the full notice is found.
  280.      ONE LINE TO GIVE THE PROGRAM'S NAME AND AN IDEA OF WHAT IT DOES.
  281.      Copyright (C) 19YY  NAME OF AUTHOR
  282.      
  283.      This program is free software; you can redistribute it and/or
  284.      modify it under the terms of the GNU General Public License
  285.      as published by the Free Software Foundation; either version 2
  286.      of the License, or (at your option) any later version.
  287.      
  288.      This program is distributed in the hope that it will be useful,
  289.      but WITHOUT ANY WARRANTY; without even the implied warranty of
  290.      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  291.      GNU General Public License for more details.
  292.      
  293.      You should have received a copy of the GNU General Public License
  294.      along with this program; if not, write to the Free Software
  295.      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  296.    Also add information on how to contact you by electronic and paper
  297. mail.
  298.    If the program is interactive, make it output a short notice like
  299. this when it starts in an interactive mode:
  300.      Gnomovision version 69, Copyright (C) 19YY NAME OF AUTHOR
  301.      Gnomovision comes with ABSOLUTELY NO WARRANTY; for details
  302.      type `show w'.  This is free software, and you are welcome
  303.      to redistribute it under certain conditions; type `show c'
  304.      for details.
  305.    The hypothetical commands `show w' and `show c' should show the
  306. appropriate parts of the General Public License.  Of course, the
  307. commands you use may be called something other than `show w' and `show
  308. c'; they could even be mouse-clicks or menu items--whatever suits your
  309. program.
  310.    You should also get your employer (if you work as a programmer) or
  311. your school, if any, to sign a "copyright disclaimer" for the program,
  312. if necessary.  Here is a sample; alter the names:
  313.      Yoyodyne, Inc., hereby disclaims all copyright
  314.      interest in the program `Gnomovision'
  315.      (which makes passes at compilers) written
  316.      by James Hacker.
  317.      
  318.      SIGNATURE OF TY COON, 1 April 1989
  319.      Ty Coon, President of Vice
  320.    This General Public License does not permit incorporating your
  321. program into proprietary programs.  If your program is a subroutine
  322. library, you may consider it more useful to permit linking proprietary
  323. applications with the library.  If this is what you want to do, use the
  324. GNU Library General Public License instead of this License.
  325. File: elisp,  Node: Introduction,  Next: Types of Lisp Object,  Prev: Copying,  Up: Top
  326. Introduction
  327. ************
  328.    Most of the GNU Emacs text editor is written in the programming
  329. language called Emacs Lisp.  You can write new code in Emacs Lisp and
  330. install it as an extension to the editor.  However, Emacs Lisp is more
  331. than a mere "extension language"; it is a full computer programming
  332. language in its own right.  You can use it as you would any other
  333. programming language.
  334.    Because Emacs Lisp is designed for use in an editor, it has special
  335. features for scanning and parsing text as well as features for handling
  336. files, buffers, displays, subprocesses, and so on.  Emacs Lisp is
  337. closely integrated with the editing facilities; thus, editing commands
  338. are functions that can also conveniently be called from Lisp programs,
  339. and parameters for customization are ordinary Lisp variables.
  340.    This manual describes Emacs Lisp, presuming considerable familiarity
  341. with the use of Emacs for editing.  (See `The GNU Emacs Manual', for
  342. this basic information.)  Generally speaking, the earlier chapters
  343. describe features of Emacs Lisp that have counterparts in many
  344. programming languages, and later chapters describe features that are
  345. peculiar to Emacs Lisp or relate specifically to editing.
  346.    This is edition 2.0.
  347. * Menu:
  348. * Caveats::             Flaws and a request for help.
  349. * Lisp History::        Emacs Lisp is descended from Maclisp.
  350. * Conventions::         How the manual is formatted.
  351. * Acknowledgements::    The authors, editors, and sponsors of this manual.
  352. File: elisp,  Node: Caveats,  Next: Lisp History,  Prev: Introduction,  Up: Introduction
  353. Caveats
  354. =======
  355.    This manual has gone through numerous drafts.  It is nearly complete
  356. but not flawless.  There are a few sections which are not included,
  357. either because we consider them secondary (such as most of the
  358. individual modes) or because they are yet to be written.
  359.    Because we are not able to deal with them completely, we have left
  360. out several parts intentionally.  This includes most references to VMS
  361. and all information relating Sunview.  (The Free Software Foundation
  362. expends no effort on support for Sunview, since we believe users should
  363. use the free X window system rather than proprietary window systems.)
  364.    The manual should be fully correct in what it does cover, and it is
  365. therefore open to criticism on anything it says--from specific examples
  366. and descriptive text, to the ordering of chapters and sections.  If
  367. something is confusing, or you find that you have to look at the sources
  368. or experiment to learn something not covered in the manual, then perhaps
  369. the manual should be fixed.  Please let us know.
  370.    As you use this manual, we ask that you send corrections as soon as
  371. you find them.  If you think of a simple, real life example for a
  372. function or group of functions, please make an effort to write it up
  373. and send it in.  Please reference any comments to the node name and
  374. function or variable name, as appropriate.  Also state the number of
  375. the edition which you are criticizing.
  376.    Please mail comments and corrections to
  377.      bug-lisp-manual@prep.ai.mit.edu
  378.       --Bil Lewis, Dan LaLiberte, Richard Stallman
  379. File: elisp,  Node: Lisp History,  Next: Conventions,  Prev: Caveats,  Up: Introduction
  380. Lisp History
  381. ============
  382.    Lisp (LISt Processing language) was first developed in the late 1950s
  383. at the Massachusetts Institute of Technology for research in artificial
  384. intelligence.  The great power of the Lisp language makes it superior
  385. for other purposes as well, such as writing editing commands.
  386.    Dozens of Lisp implementations have been built over the years, each
  387. with its own idiosyncrasies.  Many of them were inspired by Maclisp,
  388. which was written in the 1960's at MIT's Project MAC.  Eventually the
  389. implementors of the descendents of Maclisp came together and developed a
  390. standard for Lisp systems, called Common Lisp.
  391.    GNU Emacs Lisp is largely inspired by Maclisp, and a little by Common
  392. Lisp.  If you know Common Lisp, you will notice many similarities.
  393. However, many of the features of Common Lisp have been omitted or
  394. simplified in order to reduce the memory requirements of GNU Emacs.
  395. Sometimes the simplifications are so drastic that a Common Lisp user
  396. might be very confused.  We will occasionally point out how GNU Emacs
  397. Lisp differs from Common Lisp.  If you don't know Common Lisp, don't
  398. worry about it; this manual is self-contained.
  399. File: elisp,  Node: Conventions,  Next: Acknowledgements,  Prev: Lisp History,  Up: Introduction
  400. Conventions
  401. ===========
  402.    This section explains the notational conventions that are used in
  403. this manual.  You may want to skip this section and refer back to it
  404. later.
  405. * Menu:
  406. * Some Terms::               Explanation of terms we use in this manual.
  407. * nil and t::                How the symbols `nil' and `t' are used.
  408. * Evaluation Notation::      The format we use for examples of evaluation.
  409. * Printing Notation::        The format we use for examples that print output.
  410. * Error Messages::           The format we use for examples of errors.
  411. * Buffer Text Notation::     The format we use for buffer contents in examples.
  412. * Format of Descriptions::   Notation for describing functions, variables, etc.
  413. File: elisp,  Node: Some Terms,  Next: nil and t,  Prev: Conventions,  Up: Conventions
  414. Some Terms
  415. ----------
  416.    Throughout this manual, the phrases "the Lisp reader" and "the Lisp
  417. printer" are used to refer to those routines in Lisp that convert
  418. textual representations of Lisp objects into actual objects, and vice
  419. versa.  *Note Printed Representation::, for more details.  You, the
  420. person reading this manual, are thought of as "the programmer" and are
  421. addressed as "you".  "The user" is the person who uses Lisp programs
  422. including those you write.
  423.    Examples of Lisp code appear in this font or form: `(list 1 2 3)'.
  424. Names that represent arguments or metasyntactic variables appear in
  425. this font or form: FIRST-NUMBER.
  426. File: elisp,  Node: nil and t,  Next: Evaluation Notation,  Prev: Some Terms,  Up: Conventions
  427. `nil' and `t'
  428. -------------
  429.    In Lisp, the symbol `nil' is overloaded with three meanings: it is a
  430. symbol with the name `nil'; it is the logical truth value FALSE; and it
  431. is the empty list--the list of zero elements.  When used as a variable,
  432. `nil' always has the value `nil'.
  433.    As far as the Lisp reader is concerned, `()' and `nil' are
  434. identical: they stand for the same object, the symbol `nil'.  The
  435. different ways of writing the symbol are intended entirely for human
  436. readers.  After the Lisp reader has read either `()' or `nil', there is
  437. no way to determine which representation was actually written by the
  438. programmer.
  439.    In this manual, we use `()' when we wish to emphasize that it means
  440. the empty list, and we use `nil' when we wish to emphasize that it
  441. means the truth value FALSE.  That is a good convention to use in Lisp
  442. programs also.
  443.      (cons 'foo ())                ; Emphasize the empty list
  444.      (not nil)                     ; Emphasize the truth value FALSE
  445.    In contexts where a truth value is expected, any non-`nil' value is
  446. considered to be TRUE.  However, `t' is the preferred way to represent
  447. the truth value TRUE.  When you need to choose a value which represents
  448. TRUE, and there is no other basis for choosing, use `t'.  The symbol
  449. `t' always has value `t'.
  450.    In Emacs Lisp, `nil' and `t' are special symbols that always
  451. evaluate to themselves.  This is so that you do not need to quote them
  452. to use them as constants in a program.  An attempt to change their
  453. values results in a `setting-constant' error.  *Note Accessing
  454. Variables::.
  455. File: elisp,  Node: Evaluation Notation,  Next: Printing Notation,  Prev: nil and t,  Up: Conventions
  456. Evaluation Notation
  457. -------------------
  458.    A Lisp expression that you can evaluate is called a "form".
  459. Evaluating a form always produces a result, which is a Lisp object.  In
  460. the examples in this manual, this is indicated with `=>':
  461.      (car '(1 2))
  462.           => 1
  463. You can read this as "`(car '(1 2))' evaluates to 1".
  464.    When a form is a macro call, it expands into a new form for Lisp to
  465. evaluate.  We show the result of the expansion with `==>'.  We may or
  466. may not show the actual result of the evaluation of the expanded form.
  467.      (third '(a b c))
  468.           ==> (car (cdr (cdr '(a b c))))
  469.           => c
  470.    Sometimes to help describe one form we show another form which
  471. produces identical results.  The exact equivalence of two forms is
  472. indicated with `=='.
  473.      (make-sparse-keymap) == (list 'keymap)
  474. File: elisp,  Node: Printing Notation,  Next: Error Messages,  Prev: Evaluation Notation,  Up: Conventions
  475. Printing Notation
  476. -----------------
  477.    Many of the examples in this manual print text when they are
  478. evaluated.  If you execute the code from an example in a Lisp
  479. Interaction buffer (such as the buffer `*scratch*'), the printed text
  480. is inserted into the buffer.  If the example is executed by other means
  481. (such as by evaluating the function `eval-region'), the text printed is
  482. usually displayed in the echo area.  You should be aware that text
  483. displayed in the echo area is truncated to a single line.
  484.    In examples that print text, the printed text is indicated with
  485. `-|', irrespective of how the form is executed.  The value returned by
  486. evaluating the form (here `bar') follows on a separate line.
  487.      (progn (print 'foo) (print 'bar))
  488.           -| foo
  489.           -| bar
  490.           => bar
  491. File: elisp,  Node: Error Messages,  Next: Buffer Text Notation,  Prev: Printing Notation,  Up: Conventions
  492. Error Messages
  493. --------------
  494.    Some examples cause errors to be signaled.  In them, the error
  495. message (which always appears in the echo area) is shown on a line
  496. starting with `error-->'.  Note that `error-->' itself does not appear
  497. in the echo area.
  498.      (+ 23 'x)
  499.      error--> Wrong type argument: integer-or-marker-p, x
  500. File: elisp,  Node: Buffer Text Notation,  Next: Format of Descriptions,  Prev: Error Messages,  Up: Conventions
  501. Buffer Text Notation
  502. --------------------
  503.    Some examples show modifications to text in a buffer, with "before"
  504. and "after" versions of the text.  In such cases, the entire contents
  505. of the buffer in question are included between two lines of dashes
  506. containing the buffer name.  In addition, the location of point is shown
  507. as `-!-'.  (The symbol for point, of course, is not part of the text in
  508. the buffer; it indicates the place *between* two characters where point
  509. is located.)
  510.      ---------- Buffer: foo ----------
  511.      This is the -!-contents of foo.
  512.      ---------- Buffer: foo ----------
  513.      
  514.      (insert "changed ")
  515.           => nil
  516.      ---------- Buffer: foo ----------
  517.      This is the changed -!-contents of foo.
  518.      ---------- Buffer: foo ----------
  519. File: elisp,  Node: Format of Descriptions,  Prev: Buffer Text Notation,  Up: Conventions
  520. Format of Descriptions
  521. ----------------------
  522.    Functions, variables, macros, commands, user options, and special
  523. forms are described in this manual in a uniform format.  The first line
  524. of a description contains the name of the item followed by its
  525. arguments, if any.  The category--function, variable, or
  526. whatever--appears at the beginning of the line.  The description
  527. follows on succeeding lines, sometimes with examples.
  528. * Menu:
  529. * A Sample Function Description::
  530. * A Sample Variable Description::
  531. File: elisp,  Node: A Sample Function Description,  Next: A Sample Variable Description,  Prev: Format of Descriptions,  Up: Format of Descriptions
  532. A Sample Function Description
  533. .............................
  534.    In a function description, the name of the function being described
  535. appears first.  It is followed on the same line by a list of parameters.
  536. The names used for the parameters are also used in the body of the
  537. description.
  538.    The appearance of the keyword `&optional' in the parameter list
  539. indicates that the arguments for subsequent parameters may be omitted
  540. (omitted parameters default to `nil').  Do not write `&optional' when
  541. you call the function.
  542.    The keyword `&rest' (which will always be followed by a single
  543. parameter) indicates that any number of arguments can follow.  The value
  544. of the single following parameter will be a list of all these arguments.
  545. Do not write `&rest' when you call the function.
  546.    Here is a description of an imaginary function `foo':
  547.  - Function: foo INTEGER1 &optional INTEGER2 &rest INTEGERS
  548.      The function `foo' subtracts INTEGER1 from INTEGER2, then adds all
  549.      the rest of the arguments to the result.  If INTEGER2 is not
  550.      supplied, then the number 19 is used by default.
  551.           (foo 1 5 3 9)
  552.                => 16
  553.           (foo 5)
  554.                => 14
  555.      More generally,
  556.           (foo W X Y...)
  557.           ==
  558.           (+ (- X W) Y...)
  559.    Any parameter whose name contains the name of a type (e.g., INTEGER,
  560. INTEGER1 or BUFFER) is expected to be of that type.  A plural of a type
  561. (such as BUFFERS) often means a list of objects of that type.
  562. Parameters named OBJECT may be of any type.  (*Note Types of Lisp
  563. Object::, for a list of Emacs object types.) Parameters with other
  564. sorts of names (e.g., NEW-FILE) are discussed specifically in the
  565. description of the function.  In some sections, features common to
  566. parameters of several functions are described at the beginning.
  567.    *Note Lambda Expressions::, for a more complete description of
  568. optional and rest arguments.
  569.    Command, macro, and special form descriptions have the same format,
  570. but the word `Function' is replaced by `Command', `Macro', or `Special
  571. Form', respectively.  Commands are simply functions that may be called
  572. interactively; macros process their arguments differently from functions
  573. (the arguments are not evaluated), but are presented the same way.
  574.    Special form descriptions use a more complex notation to specify
  575. optional and repeated parameters because they can break the argument
  576. list down into separate arguments in more complicated ways.
  577. ``[oPTIONAL-ARG]'' means that OPTIONAL-ARG is optional and
  578. `REPEATED-ARGS...' stands for zero or more arguments.  Parentheses are
  579. used when several arguments are grouped into additional levels of list
  580. structure.  Here is an example:
  581.  - Special Form: count-loop (VAR [FROM TO [INC]]) BODY...
  582.      This imaginary special form implements a loop that executes the
  583.      BODY forms and then increments the variable VAR on each iteration.
  584.      On the first iteration, the variable has the value FROM; on
  585.      subsequent iterations, it is incremented by 1 (or by INC if that
  586.      is given).  The loop exits before executing BODY if VAR equals TO.
  587.      Here is an example:
  588.           (count-loop (i 0 10)
  589.             (prin1 i) (princ " ")
  590.             (prin1 (aref vector i)) (terpri))
  591.      If FROM and TO are omitted, then VAR is bound to `nil' before the
  592.      loop begins, and the loop exits if VAR is non-`nil' at the
  593.      beginning of an iteration.  Here is an example:
  594.           (count-loop (done)
  595.             (if (pending)
  596.                 (fixit)
  597.               (setq done t)))
  598.      In this special form, the arguments FROM and TO are optional, but
  599.      must both be present or both absent.  If they are present, INC may
  600.      optionally be specified as well.  These arguments are grouped with
  601.      the argument VAR into a list, to distinguish them from BODY, which
  602.      includes all remaining elements of the form.
  603. File: elisp,  Node: A Sample Variable Description,  Prev: A Sample Function Description,  Up: Format of Descriptions
  604. A Sample Variable Description
  605. .............................
  606.    A "variable" is a name that can hold a value.  Although any variable
  607. can be set by the user, certain variables that exist specifically so
  608. that users can change them are called "user options".  Ordinary
  609. variables and user options are described using a format like that for
  610. functions except that there are no arguments.
  611.    Here is a description of the imaginary `electric-future-map'
  612. variable.
  613.  - Variable: electric-future-map
  614.      The value of this variable is a full keymap used by electric
  615.      command future mode.  The functions in this map will allow you to
  616.      edit commands you have not yet thought about executing.
  617.    User option descriptions have the same format, but `Variable' is
  618. replaced by `User Option'.
  619. File: elisp,  Node: Acknowledgements,  Prev: Conventions,  Up: Introduction
  620. Acknowledgements
  621. ================
  622.    This manual was written by Robert Krawitz, Bil Lewis, Dan LaLiberte,
  623. Richard M. Stallman and Chris Welty, the volunteers of the GNU manual
  624. group, in an effort extending over several years.  Robert J. Chassell
  625. helped to review and edit the manual, with the support of the Defense
  626. Advanced Research Projects Agency, ARPA Order 6082, arranged by Warren
  627. A. Hunt, Jr. of Computational Logic, Inc.
  628.    Corrections were supplied by Karl Berry, Jim Blandy, Bard Bloom,
  629. David Boyes, Alan Carroll, David A. Duff, Beverly Erlebacher, David
  630. Eckelkamp, Eirik Fuller, Eric Hanchrow, George Hartzell, Nathan Hess,
  631. Dan Jacobson, Jak Kirman, Bob Knighten, Frederick M. Korz, Joe Lammens,
  632. K. Richard Magill, Brian Marick, Roland McGrath, Skip Montanaro, John
  633. Gardiner Myers, Arnold D. Robbins, Raul Rockwell, Shinichirou Sugou,
  634. Kimmo Suominen, Edward Tharp, Bill Trost, Jean White, Matthew Wilding,
  635. Carl Witty, Dale Worley, Rusty Wright, and David D. Zuhn.
  636. File: elisp,  Node: Types of Lisp Object,  Next: Numbers,  Prev: Introduction,  Up: Top
  637. Lisp Data Types
  638. ***************
  639.    A Lisp "object" is a piece of data used and manipulated by Lisp
  640. programs.  For our purposes, a "type" or "data type" is a set of
  641. possible objects.
  642.    Every object belongs to at least one type.  Objects of the same type
  643. have similar structures and may usually be used in the same contexts.
  644. Types can overlap, and objects can belong to two or more types.
  645. Consequently, we can ask whether an object belongs to a particular type,
  646. but not for "the" type of an object.
  647.    A few fundamental object types are built into Emacs.  These, from
  648. which all other types are constructed, are called "primitive types".
  649. Each object belongs to one and only one primitive type.  These types
  650. include "integer", "float", "cons", "symbol", "string", "vector",
  651. "subr", "byte-code function", and several special types, such as
  652. "buffer", that are related to editing.  (*Note Editing Types::.)
  653.    Each primitive type has a corresponding Lisp function that checks
  654. whether an object is a member of that type.
  655.    Note that Lisp is unlike many other languages in that Lisp objects
  656. are "self-typing": the primitive type of the object is implicit in the
  657. object itself.  For example, if an object is a vector, it cannot be
  658. treated as a number because Lisp knows it is a vector, not a number.
  659.    In most languages, the programmer must declare the data type of each
  660. variable, and the type is known by the compiler but not represented in
  661. the data.  Such type declarations do not exist in Emacs Lisp.  A Lisp
  662. variable can have any type of value, and remembers the type of any value
  663. you store in it.
  664.    This chapter describes the purpose, printed representation, and read
  665. syntax of each of the standard types in GNU Emacs Lisp.  Details on how
  666. to use these types can be found in later chapters.
  667. * Menu:
  668. * Printed Representation::      How Lisp objects are represented as text.
  669. * Comments::                    Comments and their formatting conventions.
  670. * Programming Types::           Types found in all Lisp systems.
  671. * Editing Types::               Types specific to Emacs.
  672. * Type Predicates::             Tests related to types.
  673. * Equality Predicates::         Tests of equality between any two objects.
  674. File: elisp,  Node: Printed Representation,  Next: Comments,  Up: Types of Lisp Object
  675. Printed Representation and Read Syntax
  676. ======================================
  677.    The "printed representation" of an object is the format of the
  678. output generated by the Lisp printer (the function `print') for that
  679. object.  The "read syntax" of an object is the format of the input
  680. accepted by the Lisp reader (the function `read') for that object.
  681. Most objects have more than one possible read syntax.  Some types of
  682. object have no read syntax; except for these cases, the printed
  683. representation of an object is also a read syntax for it.
  684.    In other languages, an expression is text; it has no other form.  In
  685. Lisp, an expression is primarily a Lisp object and only secondarily the
  686. text that is the object's read syntax.  Often there is no need to
  687. emphasize this distinction, but you must keep it in the back of your
  688. mind, or you will occasionally be very confused.
  689.    Every type has a printed representation.  Some types have no read
  690. syntax, since it may not make sense to enter objects of these types
  691. directly in a Lisp program.  For example, the buffer type does not have
  692. a read syntax.  Objects of these types are printed in "hash notation":
  693. the characters `#<' followed by a descriptive string (typically the
  694. type name followed by the name of the object), and closed with a
  695. matching `>'.  Hash notation cannot be read at all, so the Lisp reader
  696. signals the error `invalid-read-syntax' whenever a `#<' is encountered.
  697.      (current-buffer)
  698.           => #<buffer objects.texi>
  699.    When you evaluate an expression interactively, the Lisp interpreter
  700. first reads the textual representation of it, producing a Lisp object,
  701. and then evaluates that object (*note Evaluation::.).  However,
  702. evaluation and reading are separate activities.  Reading returns the
  703. Lisp object represented by the text that is read; the object may or may
  704. not be evaluated later.  *Note Input Functions::, for a description of
  705. `read', the basic function for reading objects.
  706. File: elisp,  Node: Comments,  Next: Programming Types,  Prev: Printed Representation,  Up: Types of Lisp Object
  707. Comments
  708. ========
  709.    A "comment" is text that is written in a program only for the sake
  710. of humans that read the program, and that has no effect on the meaning
  711. of the program.  In Lisp, a comment starts with a semicolon (`;') if it
  712. is not within a string or character constant, and continues to the end
  713. of line.  Comments are discarded by the Lisp reader, and do not become
  714. part of the Lisp objects which represent the program within the Lisp
  715. system.
  716.    *Note Comment Tips::, for conventions for formatting comments.
  717. File: elisp,  Node: Programming Types,  Next: Editing Types,  Prev: Comments,  Up: Types of Lisp Object
  718. Programming Types
  719. =================
  720.    There are two general categories of types in Emacs Lisp: those having
  721. to do with Lisp programming, and those having to do with editing.  The
  722. former are provided in many Lisp implementations, in one form or
  723. another.  The latter are unique to Emacs Lisp.
  724. * Menu:
  725. * Integer Type::        Numbers without fractional parts.
  726. * Floating Point Type:: Numbers with fractional parts and with a large range.
  727. * Character Type::      The representation of letters, numbers and
  728.                         control characters.
  729. * Sequence Type::       Both lists and arrays are classified as sequences.
  730. * List Type::           Lists gave Lisp its name (not to mention reputation).
  731. * Array Type::          Arrays include strings and vectors.
  732. * String Type::         An (efficient) array of characters.
  733. * Vector Type::         One-dimensional arrays.
  734. * Symbol Type::         A multi-use object that refers to a function,
  735.                         variable, property list, or itself.
  736. * Lisp Function Type::  A piece of executable code you can call from elsewhere.
  737. * Lisp Macro Type::     A method of expanding an expression into another
  738.                           expression, more fundamental but less pretty.
  739. * Primitive Function Type::     A function written in C, callable from Lisp.
  740. * Byte-Code Type::      A function written in Lisp, then compiled.
  741. * Autoload Type::       A type used for automatically loading seldom-used
  742.                         functions.
  743. File: elisp,  Node: Integer Type,  Next: Floating Point Type,  Up: Programming Types
  744. Integer Type
  745. ------------
  746.    Integers are the only kind of number in GNU Emacs Lisp, version 18.
  747. The range of values for integers is -8388608 to 8388607 (24 bits; i.e.,
  748. -2**23 to 2**23 - 1) on most machines, but is 25 or 26 bits on some
  749. systems.  It is important to note that the Emacs Lisp arithmetic
  750. functions do not check for overflow.  Thus `(1+ 8388607)' is -8388608
  751. on 24-bit implementations.
  752.    The read syntax for numbers is a sequence of (base ten) digits with
  753. an optional sign.  The printed representation produced by the Lisp
  754. interpreter never has a leading `+'.
  755.      -1               ; The integer -1.
  756.      1                ; The integer 1.
  757.      +1               ; Also the integer 1.
  758.      16777217         ; Also the integer 1!
  759.                       ;   (on a 24-bit or 25-bit implementation)
  760.    *Note Numbers::, for more information.
  761. File: elisp,  Node: Floating Point Type,  Next: Character Type,  Prev: Integer Type,  Up: Programming Types
  762. Floating Point Type
  763. -------------------
  764.    Emacs version 19 supports floating point numbers, if compiled with
  765. the macro `LISP_FLOAT_TYPE' defined.  The precise range of floating
  766. point numbers is machine-specific.
  767.    The printed representation for floating point numbers requires either
  768. a decimal point (with at least one digit following), an exponent, or
  769. both.  For example, `1500.0', `15e2', `15.0e2', `1.5e3', and `.15e4'
  770. are five ways of writing a floating point number whose value is 1500.
  771. They are all equivalent.
  772.    *Note Numbers::, for more information.
  773.